﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using RRTWSEntityDSD.Dominio;
using RRTWSNegocioDSD.Dao;
using RRTWSEntityDSD.Dao;
using System.ServiceModel.Web;
using System.Net;

namespace RRTWSEntityDSD.ServiceEntidad.WFCServiceREST
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "WCFClientesService" in code, svc and config file together.
    public class WCFClientesService : IWCFClientesService
    {
        private static ClienteDAO clienteDAO = new ClienteDAO();

        public Cliente CrearCliente(Cliente clienteACrear)
        {
            string uuid = clienteACrear.uuid;
            string dni = clienteACrear.dni;
            string apellidos = clienteACrear.apellidos;
            string nombres = clienteACrear.nombres;

            if (uuid == null || dni == null || nombres == null || apellidos == null)
            {
                throw new NullReferenceException("Valores vacios");
            }
            return clienteDAO.insert(uuid, dni, apellidos, nombres);
        }

        public Cliente ObtenerCliente(string uuid)
        {
            
            if (uuid == null)
            {
                throw new NullReferenceException("valor vacio");
            }
            Cliente c = clienteDAO.getClienteByUuID(uuid);
            if (c == null)
            {
                throw new NullReferenceException("No existe cliente");
            }
            return c;
        }


        public Cliente ObtenerClientexID(string idCliente)
        {
            int _idCliente = int.Parse(idCliente);
            return clienteDAO.getClienteByID(_idCliente);
                 
        }
    }
}
